package com.taobaolite.history;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;
import java.util.Optional;

@Repository
public interface HistoryRepository extends JpaRepository<History, HistoryPK> {

    @Query("from History h where h.historyPK.user.userId = ?1")
    List<History> findByGuestId(Long guestId);

    @Query("from History h where h.historyPK.user.userId = ?1 and h.historyPK.time = ?2")
    Optional<History> indByUserIdAndTime(Long userId, Timestamp time);
}